package com.yonyou.pmclouds.safetyrectification.service.rmiimpl;

import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.entity.SuperVO;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.projectpart.entity.ProjectPartVO;
import com.yonyou.pmclouds.projectpart.upgrade.rmiimpl.AbstractProjectPartBusinessOperator;
import com.yonyou.pmclouds.safetyrectification.mapper.SafetyRectificationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 安全整改-工程部位升级服务类
 *
 * @author th
 * @date 2020/4/21 11:46
 */
@Component
public class SafetyRectificationForUpgradeService extends AbstractProjectPartBusinessOperator {

    @Autowired
    private SafetyRectificationMapper mapper;

    @Override
    protected SuperVO[] queryBusinessVOs() {
        return mapper.queryAllProjectParts();
    }

    @Override
    public String getOperateBillType() {
        return BillTypeConst.SAFETY_RECTIFICATION_BILLTYPE;
    }

    @Override
    public void updatePkProjectParts(List<ProjectPartVO> insertedVOs) throws BusinessException {
        if (insertedVOs == null || insertedVOs.isEmpty())
            return;

        // 更新pk_projectpart字段
        for (ProjectPartVO partVO : insertedVOs) {
            mapper.updatePkProjectParts(partVO.getPkProject(), partVO.getSname(), partVO.getPkProjectpart());
        }
    }
}
